#!/usr/bin/perl

sub svr_reload
{
	local($svr_id) = @_;

	$cmd_stop = "export TUXCONFIG=/tuxadmin/util/samples/tpgetsvrseqno/tuxconfig ; tmshutdown -i %svr_id%";
	$cmd_start = "export TUXCONFIG=/tuxadmin/util/samples/tpgetsvrseqno/tuxconfig ; tmboot -i %svr_id%";
	print "-svr_reload.svr_id:$svr_id\n";

	$cmd_stop =~ s/%svr_id%/$svr_id/g;
	$ss = `$cmd_stop`;
	$cmd_start =~ s/%svr_id%/$svr_id/g;
	$ss = `$cmd_start`;
}

$svr_name = @ARGV[0];

print "* Upload Server '$svr_name'\n";

$cmd_svr_ids = "export TUXCONFIG=/tuxadmin/util/samples/tpgetsvrseqno/tuxconfig ;echo psr | tmadmin -r 2>/dev/null | grep '^%svr_name%' | cut -c 36-43 ";

$cmd_svr_ids =~ s/%svr_name%/$svr_name/g;

@svr_lsts = `$cmd_svr_ids`;

$i=1;
while($svr_lsts[$i]) {
	chomp $svr_lsts[$i];

	&svr_reload($svr_lsts[$i]);

	$i++;
}
